package com.example.idachuappone.cook.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class Cook implements Serializable {
	private String page;
	private String page_size;
	private List<CookResult> results;
	private String total;

	public void parseJson(JSONObject json) {
		if (json != null) {
			if (json.has("total")) {
				this.total = json.optString("total");
			}
			if (json.has("page_size")) {
				this.total = json.optString("page_size");
			}
			if (json.has("page")) {
				this.total = json.optString("page");
			}
			if (json.has("results")) {
				JSONArray jsonArray = json.optJSONArray("results");
				this.results = new ArrayList();
				for (int i = 0; i < jsonArray.length(); i++) {
					try {
						JSONObject jsonObject = jsonArray.getJSONObject(i);
						this.results.add(new CookResult().parseJson(jsonObject));
					} catch (JSONException e) {
						e.printStackTrace();
					}
				}
			}
		}
	}

	public Cook(String total, String page_size, String page, List<CookResult> results) {
		this.total = total;
		this.page_size = page_size;
		this.page = page;
		this.results = results;
	}

	/**
	 * 
	 */
	public Cook() {
		// TODO Auto-generated constructor stub
	}

	public String getTotal() {
		return this.total;
	}

	public void setTotal(String total) {
		this.total = total;
	}

	public String getPage_size() {
		return this.page_size;
	}

	public void setPage_size(String page_size) {
		this.page_size = page_size;
	}

	public String getPage() {
		return this.page;
	}

	public void setPage(String page) {
		this.page = page;
	}

	public List<CookResult> getResults() {
		return this.results;
	}

	public void setResults(List<CookResult> results) {
		this.results = results;
	}
}
